<?php


class ModelToolRedirect301tool extends Model {

	public function saveUrls($urls) {
		   			$this->db->query("DELETE FROM " . DB_PREFIX . "url_alias WHERE query LIKE 'redirect=%'");
					
					foreach ($urls as $url) {				
						$qe =  $url['query'];
						if(strpos($url['query'],'='))
						{
							$qe = substr($url['query'],strpos($url['query'],'=')+1,strlen($url['query']));
						}
						$qe = 'redirect='.$qe;
						$this->db->query("INSERT INTO " . DB_PREFIX . "url_alias SET query = '" . $qe . "', keyword = '" .$url['keyword'] . "'");
					}
				
				return true;
	}
	
	

	
	public function getUrls() {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE query LIKE 'redirect=%' ");

		return $query->rows;
	}
	
}
?>